StartFunction Method (string, object[], object[])
Runs an XJEase function with the specified name from the project's circuit code files. The XJEase function is run asynchronously i.e. control returns immediately from this method and the XJEase code continues to run on a separate thread.
Type: Runner
Namespace: XJTAG.Integration.XJRunner
Syntax
public void StartFunction(string functionName, object[] inputArgs, object[] outputArgs)
Parameters
- functionName
Type: string
The name of the XJEase test function to run.
- inputArgs
Type: object[]
The input arguments for the function. An arbitrary number of string and integer arguments can be given, corresponding to the parameters for the function to be run.
- outputArgs
Type: object[]
The initial values for the output arguments; individual arguments can be initialised as null.
Exceptions
- RuntimeException
There was an error running the XJEase code.
- System.ArgumentException
The function name was an empty string.
- System.ArgumentNullException
Any of the arguments were null.
- System.ObjectDisposedException
The Runner has already been disposed.
Remarks
The XJEase code is run on a separate thread, and the calling application is notified when it is completed via the FunctionFinished event. The outputs of the XJEase function run are given by the Outputs field of FunctionFinishedEventArgs.
The WaitForCompletion method must be called or the WaitForCompletion method must be called and return successfully before attempting to start running any other function. The StopFunction method can be called to abort the function.
Example
In this case we call StartFunction on a Runner object to run an XJEase function from the project circuit code files. The FunctionFinished event is subscribed to in order to obtain the outputs of the XJEase function.
class Testing { Runner runner; object[] lastFunctionOutputs; void InitialiseRunner() { /* * ... * Code to obtain Runner object from project. * ... */ // Subscribe to the FunctionFinished event. runner.FunctionFinished += new EventHandler<FunctionFinishedEventArgs>(runner_FunctionFinished); // Initialise the arrays for the input and output arguments. object[] inputArgs = new object[] { 1, "hello" }; object[] outputArgs = new object[] { null }; // Start running a function. runner.StartFunction("TestFunction", inputArgs, outputArgs); } void runner_FunctionFinished(object sender, FunctionFinishedEventArgs e) { // Get the outputs returned from XJEase. lastFunctionOutputs = e.Outputs; } }
XJTAG v4.2.5
